<?php
namespace App\Common\Lib\Fun;

use App\Common as com;

class More {
	/**
	 * 比较运算
	 * @param all $value1 比较值1
	 * @param str $operators 比较运算符，支持常见的比较运算符：==、>、>=、>==、<、<=、<===、!=、!==
	 * @param all $value2 比较值2
	 */
	public static function comparison( $value1, $operators, $value2 ){
		if( ! self::isComparisonOperator( $operators ) ) throw com\Lib\Err\Exception::makeOfNew( '', com\Cla\Err\Code::$sysFunParamError );
		//de("\$return =  \$value1 {$operators} \$value2;");
		eval( "\$return =  \$value1 {$operators} \$value2;" );
		return $return;
	}
	
	/**
	 * 是否为比较运算符
	 * @param unknown $operators_operator 判断的字符
	 * @return int [0]不是 [1]是
	 */
	public static function isComparisonOperator( $operators_operator ){
		return (int)in_array( $operators_operator, [
			'==',
			'>',
			'>=',
			'>==',
			'<',
			'<=',
			'<==',
			'!=',
			'!==',
		], true );
	}
	
}